package query

import (
	"fmt"
	"go-xorm/model"
	"xorm.io/xorm"
)

func Query(engine *xorm.Engine) {
	// 查询单个记录
	var user model.User
	has, err := engine.ID(1).Get(&user)
	fmt.Println(has, err, user)

	// 条件查询
	var users []model.User
	err = engine.Where("nick_name like CONCAT('%',?,'%')", "20").Limit(10, 0).Find(&users)
	fmt.Println(err, users)
	// 复杂查询
	err = engine.SQL("SELECT * FROM users WHERE nick_name like CONCAT('%',?,'%')", "er").Find(&users)
	fmt.Println(err, users)
}
